package com.pg.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.pg.entity.kgg.EipAhMechCharact;
import com.pg.mapper.EipAhMechCharactMapper;
import com.pg.service.EipAhMechCharactService;
import com.pg.utils.Jpg2Base64Util;
import com.pg.utils.UploadFileUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 机械特性试验 服务实现类
 * </p>
 *
 * @author likl
 * @since 2020-10-26
 */
@Service
@DS("proxyDs")
@Primary
public class EipAhMechCharactServiceImpl extends ServiceImpl<EipAhMechCharactMapper, EipAhMechCharact> implements EipAhMechCharactService {

    @Autowired
    private EipAhMechCharactMapper eipAhMechCharactMapper;

    @Override
    public void saveOne(EipAhMechCharact eipAhMechCharact) {
        if (eipAhMechCharact.getFileName() != null) {
            String filePath = "/root/" + eipAhMechCharact.getFileName();
            eipAhMechCharact.setFileObj(UploadFileUtils.uploadFiles(Jpg2Base64Util.Jpg2Base64(filePath)));
            eipAhMechCharactMapper.insert(eipAhMechCharact);
        } else {
            eipAhMechCharact.setFileObj(null);
            eipAhMechCharactMapper.insert(eipAhMechCharact);
        }
    }
}
